package module03.Question4;

/**
 * 创建学生类，其中学生的信息有：学号、姓名、年龄。
 */

public class Student {

    private String id;//学号
    private String name;//姓名
    private int age;//年龄

    public Student() {
    }

    public Student(String id, String name, int age) {
        setId(id);
        setName(name);
        setAge(age);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int hashCode() {
        final int prime = 27;
        int start = 10;
        return start * prime + Integer.parseInt(id);
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (getClass() != obj.getClass())
            return false;
        Student stu = (Student) obj;
        if (id != stu.id)
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "[id = " + id + ", name = " + name + ", age = " + age + "]";
    }
}
